//
//  BN_DynamicBaseData.m
//  BabyNow
//
//  Created by 刘泽琛 on 14-3-29.
//  Copyright (c) 2014年 iMobile. All rights reserved.
//

#import "BN_DynamicBaseData.h"

@implementation BN_DynamicBaseData

- (id)init {
    if (self = [super init]) {
        
    }
    return self;
}

- (void)toDynamic_NoticeReloadList:(Dynamic_Notice_ReloadList)reloadList {
    // code...
}

- (void)tableViewRowForCellReload:(RowForCellReload)rowReload {
    // code...
}

- (void)deallocImageCache {
    SDWebImageManager *mgr = [SDWebImageManager sharedManager]; [mgr cancelAll]; [mgr.imageCache clearMemory];
}

#pragma mark
#pragma mark 用户权限 隐藏删除按钮

#pragma mark 动态
- (void)dynamicUserType:(UIButton *)button fengxiangBtn:(UIButton*)fengxiangBtn userType:(NSInteger)userType {
    
    /*
     typedef enum
     {
     ENUM_ROLE_ADMIN = 0,            // 系统管理员
     ENUM_ROLE_LEADER = 1,           // 幼儿园园长
     ENUM_ROLE_TEACHER = 2,          // 幼儿园老师
     ENUM_ROLE_CLASS_TEACHER = 3,    // 幼儿园班主任
     ENUM_ROLE_PARENT = 4           // 家长
     }ENUM_ROLE;*/
    
    // 如果当前用户为家长的话，班级动态中不显示删除小按钮
    // 如果当前用户为老师的话，家长动态中不显示删除小按钮
    
    // 取到当前用户类型
    BN_UserInfo *userInfo = [BN_UserHelper unArchiverAccountInfo];
    NSInteger currentUserType = [userInfo.userType integerValue];
    
    // 取到当前是班级动态列表 或 家长动态列表
    NSString *classOrParentStr = [[NSUserDefaults standardUserDefaults] objectForKey:USERDEFAULTS_SWITCHDYNAMIC];
    
    // 先判断用户类型，再判断动态版块类型
        switch (currentUserType) {
        case ENUM_ROLE_LEADER:
        {
            if (currentUserType == userType) {
                if ([classOrParentStr isEqualToString:@"parent"]) {
                    button.hidden = YES;
                    // fengxiangBtn.hidden = YES;
                }else {
                    button.hidden = NO;
                    // fengxiangBtn.hidden = YES;
                }
            }else {
                button.hidden = YES;
                // fengxiangBtn.hidden = YES;
            }
        }
            break;
        case ENUM_ROLE_CLASS_TEACHER:
        {
            if (currentUserType == userType) {
                if ([classOrParentStr isEqualToString:@"parent"]) {
                    button.hidden = YES;
                    // fengxiangBtn.hidden = YES;
                }else {
                    button.hidden = NO;
                    // fengxiangBtn.hidden = YES;
                }
            }else {
                button.hidden = YES;
                // fengxiangBtn.hidden = YES;
            }
        }
            break;

        case ENUM_ROLE_PARENT:
        {
            if (currentUserType == userType) {
                if ([classOrParentStr isEqualToString:@"class"]) {
                    button.hidden = YES;
                }else {
                    button.hidden = NO;
                }
            }else {
                button.hidden = YES;
            }
        }
            break;
        default:
            break;
    }
}

#pragma mark 通知

- (void)noticeUserType:(UIButton *)button fengxiangBtn:(UIButton*)fengxiangBtn userType:(NSInteger)userType {

    // 取到当前用户类型
    BN_UserInfo *userInfo = [BN_UserHelper unArchiverAccountInfo];
    NSInteger currentUserType = [userInfo.userType integerValue];
    
    // 先判断用户类型，再判断动态版块类型
    switch (currentUserType) {
        case ENUM_ROLE_LEADER:
        {
            if (currentUserType == userType) {
                button.hidden = NO;
                fengxiangBtn.hidden = YES;
            }else {
                button.hidden = YES;
                fengxiangBtn.hidden = YES;
            }
        }
            break;
        case ENUM_ROLE_CLASS_TEACHER:
        {
            if (currentUserType == userType) {
                button.hidden = NO;
                fengxiangBtn.hidden = YES;
            }else {
                button.hidden = YES;
                fengxiangBtn.hidden = YES;
            }
        }
            break;
            
        case ENUM_ROLE_PARENT:
        {
            button.hidden = YES;
        }
            break;
        default:
            break;
    }
}

- (void)dealloc
{
    NSLog(@"班级动态、家长动态、通知BaseData释放...");
}

@end
